package cn.javass.dp.memento.mymemento;

public class Player {

    private int level;

    private int life;

    public Player(int level, int life) {
        this.level = level;
        this.life = life;
    }


    //存档
    public SaveMsg saveStateToMemento() {
        return new SaveMsg(level, life);
    }

    //回档
    public void getStateFromMemento(SaveMsg sm) {
        this.life = sm.getLife();
        this.level = sm.getLevel();
    }

    //查看存档
    public void getState() {
        System.out.println("玩家血量：" + this.life);
        System.out.println("玩家等级：" + this.level);
    }

    //练级
    public void leveling () {
        this.level = this.level + 1;
        this.life = this.life + 1;
    }

    //挑战BOSS
    public boolean challengeBOSS() {
        //设置条件
        return this.level>2&&this.life>100;
    }
}
